package com.example.springmacexercise.demo.model.method;

import com.example.springmacexercise.demo.model.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@ResponseBody
@RequestMapping("/param")
public class method {
    @RequestMapping("/m1")
    public Object method_1(String name){
        System.out.println("参数name："+name);
        return "/index.html";
    }

    @RequestMapping("/m2")
    public Object method_2(Person p){
        System.out.println("对象中的name："+p.getName());
        System.out.println("对象中的password:"+p.getPassword());
        return "/index.html";
    }

    @RequestMapping("/m3")
    public Object method_3(String name,String pwd){
        System.out.println("name参数："+name);
        System.out.println("pwd参数："+pwd);
        return "/index.html";
    }

    @RequestMapping("/m4")
    public Object method_4(@RequestParam("time") String createtime){
        System.out.println("时间："+createtime);
        return "/index.html";
    }

    @RequestMapping(value = "/m5",method = RequestMethod.POST)
    public Object method_5(@RequestBody Person person){
        System.out.println("Person:"+person);
        return "rediret:/index.html";
    }

    @RequestMapping("/m6/{name}/{password}")
    public Object method_6(@PathVariable String name ,@PathVariable String password){
        System.out.println("name:"+name);
        System.out.println("password:"+password);
        return "rediret:/index.html";
    }

}
